import { createRouter, createWebHashHistory } from 'vue-router'
import GameMenu from '../views/GameMenu.vue'
// 可以使用动态的方法配置路由
const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'console',
      component: GameMenu,
      children: [
        {
          path: '',
          name: 'gameList',
          component: () => import('../views/console/GameList.vue')
        },
        {
          path: 'myGame',
          name: 'myGame',
          component: () => import('../views/mine/MyGame.vue')
        },
        {
          path: 'history',
          name: 'history',
          component: () => import('../views/mine/HistoryGame.vue')
        },
        {
          path: 'person',
          name: 'person',
          component: () => import('../views/mine/PersonCenter.vue')
        }
      ]
    },
    {
      path: '/playGame',
      name: 'playGame',
      component: () => import('../views/PlayGame.vue')
    },
    {
      path: '/peerStream',
      name: 'peerStream',
      component: () => import('../views/PeerStream.vue')
    },
    {
      path: '/:catchAll(.*)',
      name: 'error',
      component: () => import('../views/Error.vue')
    }
  ]
})

// 监听路由的变化
router.beforeEach((to, from, next) => {
  next()
})
router.afterEach(() => {})
export default router
